import { stringify } from 'qs';
import request from '@utils/request';

export async function query({ page = 0, size = 10 }) {
  return request(`/api/sys/menu?${stringify({ page, size })}`);
}

export async function addMenu({ parentId, name, icon, url, sort, description, type }) {
  return request('/api/sys/menu', {
    method: 'POST',
    body: {
      parentId,
      name,
      icon,
      url,
      sort,
      description,
      type,
    },
  });
}

export async function updateMenu({ id, parentId, name, icon, url, sort, description, type }) {
  return request(`/api/sys/menu${id}`, {
    method: 'PUt',
    body: {
      parentId,
      name,
      icon,
      url,
      sort,
      description,
      type,
    },
  });
}
